home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / hal / scripts / hal-luks-setup < prev    next >
Text File  |  2009-10-05  |  2KB  |  57 lines

  1. #!/bin/bash
  2.  
  3. # Copyright (C) 2005 W. Michael Petullo <mike@flyn.org>
  4. # Copyright (C) 2006 David Zeuthen <davidz@redhat.com>
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License version 2.
  7.  
  8. . hal-functions
  9.  
  10. locked_out() {
  11.     echo "org.freedesktop.Hal.Device.InterfaceLocked" >&2
  12.     echo "Enclosing drive/volume is locked" >&2
  13.     exit 1
  14. }
  15.  
  16. unknown_error() {
  17.         echo "org.freedesktop.Hal.Device.UnknownError" >&2
  18.         echo "Missing or empty environment variable(s)." >&2
  19.         echo "This script should be started by hald." >&2
  20.         exit 1
  21. }
  22.  
  23. if [ -z "$HAL_PROP_BLOCK_DEVICE" ] || [ -z "$HAL_PROP_INFO_UDI" ] || [ -z "$HAL_PROP_VOLUME_UUID" ] ; then
  24.     unknown_error
  25. fi
  26.  
  27. # Respect the same locks as Mount()/Unmount() etc.
  28. if [ -n "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME" ] ; then
  29.     hal-is-caller-locked-out --udi $HAL_PROP_INFO_UDI \
  30.         --interface org.freedesktop.Hal.Device.Volume \
  31.         --caller "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME"
  32.     RET=$?
  33.     if [ "$RET" != "0" ] ; then
  34.         locked_out
  35.     fi
  36.     hal-is-caller-locked-out --udi $HAL_PROP_BLOCK_STORAGE_DEVICE \
  37.         --interface org.freedesktop.Hal.Device.Storage \
  38.         --caller "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME"
  39.     RET=$?
  40.     if [ "$RET" != "0" ] ; then
  41.         locked_out
  42.     fi
  43. fi
  44.  
  45. IS_HOTPLUGGABLE=`hal-get-property --udi $HAL_PROP_BLOCK_STORAGE_DEVICE --key storage.hotpluggable`
  46. if [ "$IS_HOTPLUGGABLE" == "true" ] ; then
  47.     ACTION="org.freedesktop.hal.storage.crypto-setup-removable"
  48. elif [ "$IS_HOTPLUGGABLE" == "false" ] ; then
  49.     ACTION="org.freedesktop.hal.storage.crypto-setup-fixed"
  50. else
  51.     unknown_error
  52. fi
  53.  
  54. hal_check_priv $ACTION
  55. hal_exec_backend
  56.